deps: Replace vergen with a new support crate#2905
deps: Replace vergen with a new support crate#2905smalis-msft merged 4 commits intomicrosoft:mainfrom
Conversation
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
There was a problem hiding this comment.
Pull request overview
This PR removes the vergen dependency and replaces it with a small in-repo build-script helper crate that emits git SHA/branch information via cargo:rustc-env, reducing transitive dependency footprint while preserving build metadata.
Changes:
- Add new
support/build_rs_git_infocrate to emitBUILD_GIT_SHA/BUILD_GIT_BRANCHusing thegitCLI. - Update OpenHCL crates’
build.rsand runtime code to use the new env var names instead ofVERGEN_*. - Remove
vergenfrom workspace dependencies and lockfile.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| support/build_rs_git_info/src/lib.rs | New helper implementation for invoking git and emitting build env vars. |
| support/build_rs_git_info/Cargo.toml | Defines the new support crate and its minimal dependencies. |
| openhcl/underhill_init/src/lib.rs | Switch runtime logging to BUILD_GIT_SHA / BUILD_GIT_BRANCH. |
| openhcl/underhill_init/build.rs | Use build_rs_git_info instead of vergen. |
| openhcl/underhill_init/Cargo.toml | Replace vergen build-dependency with build_rs_git_info. |
| openhcl/underhill_crash/src/lib.rs | Switch crash metadata to BUILD_GIT_SHA. |
| openhcl/underhill_crash/build.rs | Use build_rs_git_info instead of vergen. |
| openhcl/underhill_crash/Cargo.toml | Replace vergen build-dependency with build_rs_git_info. |
| openhcl/build_info/src/lib.rs | Switch BuildInfo fields to read BUILD_GIT_SHA / BUILD_GIT_BRANCH. |
| openhcl/build_info/build.rs | Use build_rs_git_info instead of vergen. |
| openhcl/build_info/Cargo.toml | Replace vergen build-dependency with build_rs_git_info. |
| Cargo.toml | Add build_rs_git_info workspace dep; remove vergen version. |
| Cargo.lock | Lockfile updates reflecting dependency removal/addition. |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
You can also share your feedback on Copilot code review. Take the survey.
| let ref_path = git_path(&["rev-parse", "--git-path", &head_ref])?; | ||
| println!("cargo:rerun-if-changed={}", ref_path.display()); | ||
| } | ||
|
|
There was a problem hiding this comment.
cargo:rerun-if-changed only watches HEAD and (if symbolic) the loose ref file (e.g. .git/refs/heads/main). If refs are packed (common after git gc / git pack-refs), that ref file may not exist and updates like git commit --amend won’t trigger a rebuild, leaving BUILD_GIT_SHA stale. Consider also watching packed-refs (via git rev-parse --git-path packed-refs) unconditionally, or otherwise ensuring ref updates are tracked even when refs are packed.
| // Also watch the packed-refs file so ref updates are tracked even when | |
| // branch refs are packed and the loose ref files no longer exist. | |
| let packed_refs_path = git_path(&["rev-parse", "--git-path", "packed-refs"])?; | |
| println!("cargo:rerun-if-changed={}", packed_refs_path.display()); |
There was a problem hiding this comment.
I chatted with @smalis-msft offline. He experimented, and found that this is incorrect. This code will trigger a rebuild if that file doesn't exist.
The vergen crate, and especially its new version 9, pulls in a lot of dependencies for the relatively small pieces of it we use. Replace it with a new home-grown crate that has no dependencies beyond anyhow and just does what we need.